package com.chinda.modules.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chinda.common.constants.CacheConstant;
import com.chinda.common.page.RPage;
import com.chinda.modules.sys.dao.SysConfigDao;
import com.chinda.modules.sys.entity.SysConfigEntity;
import com.chinda.modules.sys.qo.SysConfigQO;
import com.chinda.modules.sys.service.SysConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


/**
 * 系统配置信息表
 *
 * @author chinda
 * @date 2021-06-16 05:52:51
 */
@Slf4j
@Service("sysConfigService")
@Transactional(readOnly = true, rollbackFor = Exception.class)
public class SysConfigServiceImpl extends ServiceImpl<SysConfigDao, SysConfigEntity> implements SysConfigService {

    /**
     * 获取分页信息
     *
     * @param qo
     * @return
     */
    @Override
    public RPage page(SysConfigQO qo) {
        return new RPage(page(qo.getPage(), qo.getQueryWrapper()));
    }

    /**
     * 根据参数key获取参数
     *
     * @param paramKey
     * @return
     */
    @Override
    public SysConfigEntity getByParamKey(String paramKey) {
        log.info("paramKey:{}", paramKey);
        return this.getOne(new LambdaQueryWrapper<SysConfigEntity>().eq(SysConfigEntity::getParamKey, paramKey));
    }
}